Don't recursively set bg none on the parent when e.g. moving children
authorAlexander Larsson <alexl@redhat.com>
Tue, 27 Jan 2009 15:43:03 +0000 (16:43 +0100)
committerAlexander Larsson <alex@localhost.localdomain>
Thu, 2 Apr 2009 08:15:28 +0000 (10:15 +0200)
To avoid drawing the window background of other windows in the area
where the window was we set the bg to none recursively. However, this
is quite costly it the moved window has many siblings. Furthermore, it
is uncommon that siblings overlap, so this cost has little gain.

So, we only set bg None on the parent, which means that there will
be some more flicker in the uncommon case of overlapping siblings.

gdk/x11/gdkgeometry-x11.c
gdk/x11/gdkwindow-x11.c
gdk/x11/gdkwindow-x11.h

index 891fd94721c9923c09aec580b42092bd46d51d8c..6bd71c3b4415a6521a59b7b3338951402d8ac968 100644 (file)
@@ -201,13 +201,16 @@ _gdk_window_move_resize_child (GdkWindow *window,
      the window won't be visible anyway and thus it will be shaped
      to nothing */
 
-  _gdk_x11_window_tmp_unset_parent_bg (window, TRUE);
+  
+  _gdk_x11_window_tmp_unset_parent_bg (window);
+  _gdk_x11_window_tmp_unset_bg (window, TRUE);
   XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window),
                     GDK_WINDOW_XID (window),
                     obj->x + obj->parent->abs_x,
                     obj->y + obj->parent->abs_y,
                     width, height);
-  _gdk_x11_window_tmp_reset_parent_bg (window, TRUE);
+  _gdk_x11_window_tmp_reset_parent_bg (window);
+  _gdk_x11_window_tmp_reset_bg (window, TRUE);
 }
 
 static Bool
index 204e6bfcfdd5153244f9844924475f96597c0502..0089d1e0e71de9003898be3bb82a37c6e5b3e750 100644 (file)
@@ -299,16 +299,16 @@ _gdk_x11_window_tmp_unset_bg (GdkWindow *window,
 }
 
 void
-_gdk_x11_window_tmp_unset_parent_bg (GdkWindow *window,
-                                    gboolean   recurse)
+_gdk_x11_window_tmp_unset_parent_bg (GdkWindow *window)
 {
   GdkWindowObject *private;
   private = (GdkWindowObject*) window;
+
+  if (GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_ROOT)
+    return;
   
-  if (GDK_WINDOW_TYPE (private->parent) != GDK_WINDOW_ROOT)
-    window = _gdk_window_get_impl_window ((GdkWindow *)private->parent);
-  
-  _gdk_x11_window_tmp_unset_bg (window,        recurse);
+  window = _gdk_window_get_impl_window ((GdkWindow *)private->parent);
+  _gdk_x11_window_tmp_unset_bg (window,        FALSE);
 }
 
 void
@@ -343,16 +343,17 @@ _gdk_x11_window_tmp_reset_bg (GdkWindow *window,
 }
 
 void
-_gdk_x11_window_tmp_reset_parent_bg (GdkWindow *window,
-                                    gboolean   recurse)
+_gdk_x11_window_tmp_reset_parent_bg (GdkWindow *window)
 {
   GdkWindowObject *private;
   private = (GdkWindowObject*) window;
 
-  if (GDK_WINDOW_TYPE (private->parent) != GDK_WINDOW_ROOT)
-    window = _gdk_window_get_impl_window ((GdkWindow *)private->parent);
+  if (GDK_WINDOW_TYPE (private->parent) == GDK_WINDOW_ROOT)
+    return;
+  
+  window = _gdk_window_get_impl_window ((GdkWindow *)private->parent);
 
-  _gdk_x11_window_tmp_reset_bg (window, recurse);
+  _gdk_x11_window_tmp_reset_bg (window, FALSE);
 }
 
 static GdkColormap*
@@ -1598,12 +1599,12 @@ gdk_window_x11_reparent (GdkWindow *window,
   impl = GDK_WINDOW_IMPL_X11 (window_private->impl);
 
   _gdk_x11_window_tmp_unset_bg (window, TRUE);
-  _gdk_x11_window_tmp_unset_parent_bg (window, FALSE);
+  _gdk_x11_window_tmp_unset_parent_bg (window);
   XReparentWindow (GDK_WINDOW_XDISPLAY (window),
                   GDK_WINDOW_XID (window),
                   GDK_WINDOW_XID (new_parent),
                   parent_private->abs_x + x, parent_private->abs_y + y);
-  _gdk_x11_window_tmp_reset_parent_bg (window, FALSE);
+  _gdk_x11_window_tmp_reset_parent_bg (window);
   _gdk_x11_window_tmp_reset_bg (window, TRUE);
 
   if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN)
@@ -3401,15 +3402,21 @@ do_shape_combine_region (GdkWindow       *window,
            private->shaped = FALSE;
          
          if (shape == ShapeBounding)
-           _gdk_x11_window_tmp_unset_parent_bg (window, TRUE);
+           {
+             _gdk_x11_window_tmp_unset_parent_bg (window);
+             _gdk_x11_window_tmp_unset_bg (window, TRUE);
+           }
          XShapeCombineMask (GDK_WINDOW_XDISPLAY (window),
                             GDK_WINDOW_XID (window),
                             shape,
                             0, 0,
                             None,
                             ShapeSet);
-         if (shape == ShapeBounding)
-           _gdk_x11_window_tmp_reset_parent_bg (window, TRUE);
+         if (shape == ShapeBounding)
+           {
+             _gdk_x11_window_tmp_reset_parent_bg (window);
+             _gdk_x11_window_tmp_reset_bg (window, TRUE);
+           }
        }
       return;
     }
@@ -3429,7 +3436,10 @@ do_shape_combine_region (GdkWindow       *window,
                                    &xrects, &n_rects);
       
       if (shape == ShapeBounding)
-       _gdk_x11_window_tmp_unset_parent_bg (window, TRUE);
+       {
+         _gdk_x11_window_tmp_unset_parent_bg (window);
+         _gdk_x11_window_tmp_unset_bg (window, TRUE);
+       }
       XShapeCombineRectangles (GDK_WINDOW_XDISPLAY (window),
                                GDK_WINDOW_XID (window),
                                shape,
@@ -3439,7 +3449,10 @@ do_shape_combine_region (GdkWindow       *window,
                                YXBanded);
 
       if (shape == ShapeBounding)
-       _gdk_x11_window_tmp_reset_parent_bg (window, TRUE);
+       {
+         _gdk_x11_window_tmp_reset_parent_bg (window);
+         _gdk_x11_window_tmp_reset_bg (window, TRUE);
+       }
       
       g_free (xrects);
     }
index 744ff2ce06f67cc69157b60669cee5e927f0cf93..0ff1b437b5cbec536808c36ff12882fd2afc9c68 100644 (file)
@@ -148,10 +148,8 @@ void            _gdk_x11_window_tmp_unset_bg        (GdkWindow *window,
                                                     gboolean   recurse);
 void            _gdk_x11_window_tmp_reset_bg        (GdkWindow *window,
                                                     gboolean   recurse);
-void            _gdk_x11_window_tmp_unset_parent_bg (GdkWindow *window,
-                                                    gboolean   recurse);
-void            _gdk_x11_window_tmp_reset_parent_bg (GdkWindow *window,
-                                                    gboolean   recurse);
+void            _gdk_x11_window_tmp_unset_parent_bg (GdkWindow *window);
+void            _gdk_x11_window_tmp_reset_parent_bg (GdkWindow *window);
 
 GdkCursor      *_gdk_x11_window_get_cursor    (GdkWindow *window);
 void            _gdk_x11_window_get_offsets   (GdkWindow *window,